package com.funcourse.demo.wechat.client.common;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

@Data
public class BaseResponse {

  @JsonProperty("errcode")
  Integer errCode;

  @JsonProperty("errmsg")
  String errMsg;

  public Boolean success(){
    return null == errCode || BaseResponse.ErrorCodes.SUCCESS.getValue().equals(errCode);
  }

  public enum ErrorCodes{
    RETRY(-1),SUCCESS(0),INVALID_JS_CODE(40029),FREQUENCY_LIMIT(45011);
    private Integer value;
    ErrorCodes(Integer i){
      this.value = i;
    }
    Integer getValue(){
      return value;
    }
  }

}
